package com.projet.glb2r.Affiche;

import com.projet.glb2r.R;
import com.projet.glb2r.Activite.ActiviteCreationFacture;
import com.projet.glb2r.Base_et_Provider.TableFacture;
import com.projet.glb2r.R.id;
import com.projet.glb2r.R.layout;
import com.projet.glb2r.R.menu;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.BaseColumns;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;

public class AfficheFacture extends Activity{
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.datefacture);

		Uri uri = getIntent().getData();
		Cursor cursor = managedQuery(uri, null, null, null, null);

		if (cursor == null) {
			finish();
		} else {
			cursor.moveToFirst();

			TextView word = (TextView) findViewById(R.id.date);
			//TextView definition = (TextView) findViewById(R.id.definition);

			int wIndex = cursor.getColumnIndexOrThrow(TableFacture.KEY_DATE);
			int Index  = cursor.getColumnIndexOrThrow(BaseColumns._ID);
			/*int cIndex = cursor.getColumnIndexOrThrow(BaseClient.KEY_ADRESSE);
			int bIndex = cursor.getColumnIndexOrThrow(BaseClient.KEY_TELEPHONE);*/
			
			ActiviteCreationFacture.objetfacture.setDate(cursor.getString(wIndex));
			ActiviteCreationFacture.objetfacture.setId(cursor.getInt(Index));
			
			/*ActiviteCreationFacture.objetclient.setAdresse(cursor.getString(cIndex));
			ActiviteCreationFacture.objetclient.setTelephone(cursor.getString(bIndex));*/
			
			word.setText(cursor.getString(wIndex));
			
			Intent intention = new Intent ("android.intent.action.ActiviteCreationFacture");
			startActivity(intention);
			
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.options_menufacture, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.searchfacture:
			onSearchRequested();
			return true;
		default:
			return false;
		}
	}
}
